export default {
	async addeStateChronicleEvent(params) {
		console.log(params)
		let _push_form = {}
		_push_form.estateId = params.estateId
		_push_form.partId = params.partId
		_push_form.startTime = params.startTime
		// _push_form.projectId = uni.getStorageSync('estateId')
		_push_form.imgs = params.images
		_push_form.eventStatus = params.eventStatus
		_push_form.feedBack = params.feedBack
		_push_form.endTime = params.endTime
		_push_form.type = params.type
		const data = await uni.$H.post('/estateChronicleEvent/add', _push_form, {
			authCode: true
		})
		if (data.status !== 0) {
			uni.$showMsg(data.message)
			return false
		} else {
			return true
		}
	},
	async modStateChronicleEvent(params) {
		console.log(params)
		let _push_form = {}
		_push_form.eventId = params.eventId
		// _push_form.estateId = params.estateId
		// _push_form.partId = params.partId
		_push_form.startTime = params.startTime
		// _push_form.projectId = uni.getStorageSync('estateId')
		_push_form.imgs = params.images
		_push_form.eventStatus = params.eventStatus
		_push_form.feedBack = params.feedBack
		_push_form.endTime = params.endTime
		// _push_form.type = params.type
		const data = await uni.$H.post('/estateChronicleEvent/mod', _push_form, {
			authCode: true
		})
		if (data.status !== 0) {
			uni.$showMsg(data.message)
			return false
		} else {
			return true
		}
	},
	// /realEstatePart/getByParent
	async getChildNode(id) {
		const data = await uni.$H.get('/realEstatePart/getByParent', {
			parentId: id
		}, {
			authCode: true
		})
		if (data.status !== 0) {
			uni.$showMsg(data.message)
			return []
		} else {
			return data.body
		}
	},
	// getNodeArray(array){
	// 	for (let i = 0; i < array.length; i++) {

	// 	}
	// }
	async getPorjectIdByEstateId(id) {
		// /developer/getByBusinessEstateId
		const data = await uni.$H.get('/developer/getByDeveloper', {
			// businessEstateId: id
		}, {
			authCode: true
		})
		if (data.status !== 0) {
			uni.$showMsg(data.message)
			return []
		} else {
			return data.body
		}
	},
	async getPartNode() {
		const data = await uni.$H.get(
			"/realEstatePart/getPartInfoByParentIdAndEstateId", {
				parentId: "id",
				estateId: uni.getStorageSync("projectId"),
			}, {
				authCode: true,
			}
		);
		if (data.status === 0) {
			if (data.body.length != 0) {
				return data.body;
			} else {
				uni.$showMsg("请先绑定地产检查项信息");
				return []
			}
		} else {
			uni.$showMsg(data.message);
			return []
		}
	},
	pushEventsArray(array) {
		let flag = 0
		for (let i = 0; i < array.length; i++) {
			if (!this.addeStateChronicleEvent(array[i])) {
				uni.$showMsg('提交失败，请稍后重试')
				break
			}
			flag++
		}
		return flag == array.length ? true : false
	},
	async getChronicleEvent(params) {
		console.log(params)
		let _push_form = {}
		if (typeof params.estateId == undefined || params.estateId == null) {
			_push_form.estateIds = []
			_push_form.partId = params.rootPartId
			_push_form.businessEstateId = uni.getStorageSync('estateId')
		} else {
			_push_form.estateIds = [params.estateId]
			_push_form.partId = params.rootPartId
			//调整
		}
		// _push_form.rootPartId = params.rootPartId
		// _push_form.startTime = params.startTime
		// _push_form.imgs = params.images
		// _push_form.eventStatus = params.eventStatus
		// _push_form.feedBack = params.feedBack
		_push_form.statusList = params.statusList
		_push_form.type = params.type
		const data = await uni.$H.post('/estateChronicleEvent/getList', _push_form, {
			authCode: true
		})
		if (data.status !== 0) {
			uni.$showMsg(data.message)
			return []
		} else {
			return data.body
		}
	},
	// /estateChronicleEvent/delete
	async deleteEvent(id) {
		const data = await uni.$H.post('/estateChronicleEvent/delete', {
			eventId: id
		}, {
			authCode: true
		})
		if (data.status !== 0) {
			uni.$showMsg(data.message)
			return false
		} else {
			return true
		}
	}
}
